package operator;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-18
 */
public class AddOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("开始添加图书");
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入要添加的书名");
        String name = scan.next();
        System.out.println("请输入要添加的作者");
        String author = scan.next();
        System.out.println("请输入要添加的价格");
        float price = scan.nextFloat();

        int size = bookList.getSize();
        Book book = new Book(name, author, price);
        bookList.setPos(book, size);
        bookList.setSize(size + 1);
        System.out.println("添加成功");
    }
}
